// 引入 Mock
import Mock from "mockjs";

// 定义数据类型
let { data } = Mock.mock({
  // 20条数据
  "data|76": [
    {
      "id|+1": 1,
      name: "@cname",

      "huodongshijian|2003058804-183058804": 1403058804,
      //商品名称
      goodsName: "@ctitle(20)",
    },
  ],
});
// 输出结果随机生成的数据（node index.js）
// console.log(data);

Mock.mock("/api/list", "post", (option) => {
  const { currentPage, pageSize } = JSON.parse(option.body);
  // (currentPage - 1) * pageSize
  // currentPage * pageSize

  const result = data.slice(
    (currentPage - 1) * pageSize,
    currentPage * pageSize
  );
  return {
    result: result,
    status: 0,
    total: data.length,
  };
});


export default Mock;

